<%namespace name="admin_include" file="/admin/base/include.html" />
<%inherit file="/front/base/normalbase.html"/>
<%def name="center()">
<%!
import datetime
%>
<div class="row">
    <h3 class="lit page-header no-margin" style="margin-bottom:10px;">我的购物车</h3>
    <table class="table table-bordered table-striped" style="table-layout:fixed;">
        <thead class="typ">
            <tr>
                <th width="15" style="text-align:center"></th>
                <th width="90" style="text-align:center">商品</th>
                <th width="15" style="text-align:center">数量</th>
                <th width="20" style="text-align:center">单价</th>
                <th width="20" style="text-align:center">小计</th>
                <th width="20" style="text-align:center">操作</th>
            </tr>
        </thead>
        <tbody>
            <%
            sum_price = 0
            %>
            %if request.session.has_key('shoppingcart'):
            %for detail in request.session['shoppingcart']:
            <%
            sum_price = sum_price + detail.number*detail.sellprice
            %>
            <tr>
                <td>
                    <p><img src="${detail.picture}"/></p>
                </td>
                <td>
                    <p><a href="/products/detail/${detail.product_id}.html" target="_blank">${detail.name}</a></p>
                </td>
                <td style="text-align:center;">
                    <p>${detail.number}</p>
                </td>
                <td style="text-align:center;">
                    <p class="no-margin">¥${detail.sellprice}</p>
                </td>
                <td style="text-align:center;">
                    <p class="no-margin">¥${detail.number * detail.sellprice}</p>
                </td>
                <td>
                    <p style="text-align:center;"><a href="/products/shoppingcartdelete/${detail.product_id}.html">删除</a></p>
                </td>
            </tr>
            %endfor
            <tr>
                <td colspan="6">
                    <p style="padding-left:60px;" class="pull-right">总计:<span class="label label-success" style="font-size:16px;margin-left:20px;">¥${sum_price}</span></p>
                </td>
            </tr>
            %endif
        </tbody>
    </table>
    <p>
        <a class="btn" href="${back_url}">继续购物</a>
        <%
        if not h.is_user_login(request):
            payurl = '/user/login.html?backurl=/products/createorder.html'
        else:
            payurl = '/products/createorder.html'
        %>

        %if request.session.has_key('shoppingcart') and len(request.session['shoppingcart']) > 0:
        <a class="btn btn-primary btn-large" style="margin-left:700px;" href="${payurl}">&nbsp;&nbsp;&nbsp;去结算&nbsp;&nbsp;&nbsp;</a>
        %endif
    </p>
</div>
</%def>


<%def name="script()">
<script type="text/javascript">
</script>
</%def>
